package com.xyy.yueshijia.presenter;

import android.util.Log;

import com.xyy.yueshijia.base.BasePresenter;
import com.xyy.yueshijia.bean.shop.StoreBannerBean;
import com.xyy.yueshijia.bean.shop.StoreBean;
import com.xyy.yueshijia.bean.shop.StoreChannelBean;
import com.xyy.yueshijia.bean.shop.StoreDatasBean;
import com.xyy.yueshijia.bean.shop.StoreQueryBean;
import com.xyy.yueshijia.bean.shop.StoreTag_ClassifyBean;
import com.xyy.yueshijia.modle.StroeModle;
import com.xyy.yueshijia.utils.JSonUtils;
import com.xyy.yueshijia.view.impl.StoreView;

import java.util.List;
import java.util.Map;

import rx.Subscriber;

/**
 * Created by lxs on 2017/2/8.
 */

public class StorePresenter extends BasePresenter<StoreView> {
    StroeModle modle;

    public StorePresenter() {
        this.modle = new StroeModle();
    }

    public void getModelData(Map<String, String> params){
        modle.getShopStringData(params, new Subscriber<String>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(String s) {

                StoreBean shopBean = JSonUtils.getStoreData(s);
                StoreDatasBean shopDatas = shopBean.getStoreDatasBean();

                List<StoreQueryBean> shopQueryBeanList = shopDatas.getStoreQueryBean();

                List<StoreBannerBean> shopBannerBeanList = shopDatas.getStoreBannerBean();

                List<StoreTag_ClassifyBean> shopTagBeanList = shopDatas.getStoreTag_classifyBean();
                Log.i("tag","----------------sss11111ssss----------");
                StoreChannelBean shopChannel = shopDatas.getStoreChannelBean();

                if(shopChannel!=null
                        &&!shopQueryBeanList.isEmpty()
                        &&!shopBannerBeanList.isEmpty()
                        &&!shopTagBeanList.isEmpty()){
                    mView.onSuccess(shopBannerBeanList
                            ,shopTagBeanList
                            ,shopChannel
                            ,shopQueryBeanList);
                    Log.i("tag","----------------ssssssssss----------");
                }
            }
        });
    }

}